<?php require_once('auth.php'); ?>
<html>
<head>
<title>MCS Image Tool</title>
<script type="text/javascript" src="simpletreemenu.js"></script>
<link rel="stylesheet" type="text/css" href="simpletree.css" />
</head>
<body>

<div id="exco" style="position:fixed; left:800px; top:200px">
<a href="javascript:ddtreemenu.flatten('treemenu3', 'expand')" style="font-family:'Arial';font-size:14pt;color:black;filter:Glow(color=#ff0000,strength=12);">Expand All</a> | <a href="javascript:ddtreemenu.flatten('treemenu3', 'contact')"style="font-family:'Arial';font-size:14pt;color:#000000;filter:Glow(color=#ff0000,strength=12);">Collapse All</a>
</div>

<div style="width:50%;border: 1px solid black;background-color:#ffffff; layer-background-color:#003366; visibility: visible">
<ul id="treemenu3" class="treeview">
<?php
include  "scandr2.php"	;
//$path = "/opt/lampp/htdocs/music/music";
$path = "/home/rockedg1/public_html/badge/uploads";
$iii = 0;
$filestructure= scan_directory_recursively($path, false);
      $i = 0;
	 while ($i < count($filestructure)) {
	    $name =  $filestructure[$i]['name']  ;
		$kind =  $filestructure[$i]['kind']  ;
		$content =  $filestructure[$i]['content']  ;
	   	$path =  $filestructure[$i]['path']  ;
		 if($kind =='directory'){
		   echo "<li>".$name."\n";
		  echo "<ul>"."\n";;
		   echo scan_d($content,0);
		   echo "</ul>"."\n";
		 }
		 else{
		 //echo "<li><a href='".get_path($path)."' target='_blank'>".$name."</a></li>"."\n";
	   	  
		 echo "<li><a href='show_img.php?id=$path' target='iFrame1'>".$name."</a></li>"."\n";
		 
		 //echo "<li><form method='post' action='show_img.php'><input name='id' type='submit' value='".$send_img."'></form></li>"; 	 
			 }
  
	   ++$i;
	  }

function get_path($path) {
  $len = strlen($path);
  $pos = strpos($path,'/uploads/');
  $http_path =  substr($path,$pos,$len);
	  return $http_path;
}
?>
<?php
		  
function scan_d($array,$level){	  
		  
		   
		  for($ii=0;$ii< count($array);$ii++){
			  $kind =  $array[$ii]['kind']  ;
			  $name = $array[$ii]['name'];
		if ($kind=='file')  {
			$path = $array[$ii]['path']  ;
			//echo "<li><a href='".get_path($path)."' target='_blank'>".$name."</a></li>"."\n";
    	 	 echo "<li><a href='show_img.php?id=$path' target='iFrame1'>".$name."</a></li>"."\n";
		 //$send_img =($path);
		 //$send_img = get_path($path);
		 //echo "<li><form method='post' action='show_img.php'><input name='id' type='submit' value='".$send_img."'></form></li>"; 	
		}
		else{
			echo "<li>".$name."\n";
			}	
		   			
					if ($kind =='directory'){
					$sub_array = $array[$ii]['content'];
					  echo "<ul>"."\n";
					scan_d($sub_array,1);
					  echo"</ul>"."\n";
						
					}
					
		   }
	  
}
?>
</ul>
<script type="text/javascript">
ddtreemenu.createTree("treemenu3", true)
</script>
<div id="iFrame1" style="position:fixed; left:800px; top:241px; z-index:6">
<!--<div id="iFrame1" style="float:right;">	-->
<!--<div id="iFrame1" style="position:absolute; left:514px; top:441px; z-index:6">	-->
<iframe name="iFrame1" width="400" height="340" src="blank.php" scrolling="no" frameborder="0"></iframe>
</div>
<div id="exco" style="position:fixed; left:800px; top:100px">
<form name="form1" method="post" action="insert_photo.php" enctype="multipart/form-data" style="margin:0px" target='iFrame1'>
<input name="datei" type="file" >
<input name="formbutton1" type="submit" value="Upload!" >
<input name="formbutton2" type="reset" value="Clear" >
</form>
<p><a href="parse_2.php"><img src="images/refresh.png" alt="missing">&nbsp;&nbsp;Refresh File Tree</a></p>
</div>
</body>
</html>